package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.sysadmin.zsj.domain.Activity;
import com.hjxr.sysadmin.zsj.service.IActivityService;


/**
 * 招商活动信息Controller
 *
 * @author xk
 * @date 2021-03-23
 */
@Api("招商活动信息")
@RestController
@RequestMapping("/zsj/activity")
public class ActivityController extends BaseController
{
    @Autowired
    private IActivityService activityService;

    /**
     * 查询招商活动信息列表
     */
    @ApiOperation("查询招商活动信息列表")
    @GetMapping("/list")
    public TableDataInfo list(Activity activity)
    {
        startPage();
        List<Activity> list = activityService.selectActivityList(activity);
        return getDataTable(list);
    }

    /**
     * 导出招商活动信息列表
     */
    @ApiOperation("导出招商活动信息列表")
    @Log(title = "招商活动信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Activity activity)
    {
        List<Activity> list = activityService.selectActivityList(activity);
        ExcelUtil<Activity> util = new ExcelUtil<Activity>(Activity.class);
        return util.exportExcel(list, "activity");
    }

    /**
     * 获取招商活动信息详细信息
     */
    @ApiOperation("获取招商活动信息详细信息")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId)
    {
        return AjaxResult.success(activityService.selectActivityById(activityId));
    }

    /**
     * 新增招商活动信息
     */
    @ApiOperation("新增招商活动信息")
    @Log(title = "招商活动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Activity activity)
    {
        return toAjax(activityService.insertActivity(activity));
    }

    /**
     * 修改招商活动信息
     */
    @ApiOperation("修改招商活动信息")
    @Log(title = "招商活动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Activity activity)
    {
        return toAjax(activityService.updateActivity(activity));
    }

    /**
     * 删除招商活动信息
     */
    @ApiOperation("删除招商活动信息")
    @Log(title = "招商活动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(activityService.deleteActivityByIds(activityIds));
    }
}
